/**
 * Created by liyongliang on 15/9/18.
 */
var gulp = require('gulp');
var sass = require('gulp-sass');
var handleErrors = require('../util/handleErrors');
var minifyCss = require('gulp-minify-css');
var rename = require('gulp-rename');
var config = require('../config').sass;
var autoprefixer = require('gulp-autoprefixer');
var ifDevReload = require('../util/gulp-if-dev-reload');
var notify = require('gulp-notify');

gulp.task('sass', function () {
    return gulp.src(config.src)
        .pipe(sass(config.settings).on('error', handleErrors))
        .pipe(autoprefixer({
            browsers: ['last 2 version']
        }))
        .pipe(gulp.dest(config.dest))
        .pipe(ifDevReload())
        .pipe(minifyCss({
            keepSpecialComments: 0
        }))
        .pipe(rename({
            extname: '.min.css'
        }))
        .pipe(gulp.dest(config.dest))
        .pipe(ifDevReload())
        .pipe(notify({
            message: 'Sass任务完成更新~~'
        }));
});
